import request from '@/utils/request';
import { ProductCategory } from '../models/productCategory';

const prefix = '/products/categories';

export async function list(): Promise<any> {
  return request(prefix);
}

export async function get(id: number): Promise<ProductCategory> {
  return request(`${prefix}/${id}`);
}

export async function add(formData: any): Promise<any> {
  return request(`${prefix}/create`, {
    method: 'POST',
    data: formData,
  });
}

export async function update(payload: ProductCategory): Promise<ProductCategory> {
  return request(`${prefix}/${payload.id}`, {
    method: 'PUT',
    data: payload,
  });
}

export async function remove(id: number): Promise<any> {
  return request(`${prefix}/${id}`, {
    method: 'DELETE',
  });
}
